package io;

import java.io.UnsupportedEncodingException;

public class JavaEncode {
	public static void main(String[] args) {
		encode();
	}
	private static void encode(){
		String name = "中"; 
        try { 
            byte[] iso8859 = name.getBytes("ISO-8859-1"); 
            System.out.println("ISO-8859-1: "+ByteToHex.bytesToHexString(iso8859));
            byte[] gb2312 = name.getBytes("GB2312"); 
            System.out.println("GB2312: "+ByteToHex.bytesToHexString(gb2312)); 
            byte[] gbk = name.getBytes("GBK"); 
            System.out.println("GBK: "+ByteToHex.bytesToHexString(gbk)); 
            byte[] utf16 = name.getBytes("UTF-16"); 
            System.out.println("UTF-16: "+ByteToHex.bytesToHexString(utf16)); 
            byte[] utf8 = name.getBytes("UTF-8"); 
            System.out.println(ByteToHex.bytesToBinaryString(utf8));
            System.out.println("UTF-8: "+ByteToHex.bytesToHexString(utf8)); 
        } catch (UnsupportedEncodingException e) { 
            e.printStackTrace(); 
        } 
	}
}
